<template>
  <div class="hello">
    <!-- <transition name="xfy">
      <h1 v-if="isShow">{{ msg }}</h1>
    </transition> -->
    <h1>{{ msg }}</h1>
    <h2>{{ modelValue }}</h2>
    <button @click="btnClick">改变modelValue</button>
    <input type="text" v-model="newmessage" />
    <input type="text" v-model="newname" />
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  props: {
    msg: String,
    modelValue: String,
    xfy: String,
  },
  data() {
    return {
      isShow: true,
    };
  },
  computed: {
    newmessage: {
      get() {
        return this.modelValue;
      },
      set(val) {
        console.log("计算属性改变了");
        this.$emit("update:modelValue", val);
      },
    },
    newname: {
      get() {
        return this.xfy;
      },
      set(val) {
        this.$emit("update:xfy", val);
      },
    },
  },
  emits: ["update:modelValue", "update:xfy"],
  methods: {
    btnClick() {
      this.$emit("update:modelValue", "这是被改变后的值");
    },
    changeShow() {
      this.isShow = !this.isShow;
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* 开始状态 */
.xfy-enter-form,
.xfy-leave-to {
  opacity: 0;
}

/* 最终方案 */
.xfy-leave-from,
.xfy-enter-to {
  opacity: 1;
}
.xfy-enter-active,
.xfy-leave-active {
  transition: opacity 2s;
}
</style>
